package com.yuexun.dhdoctor.module.meetingNew.adapter;

import android.view.View;
import android.widget.AbsListView;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.TextView;


import com.yuexun.dhdoctor.R;
import com.yuexun.dhdoctor.module.meetingNew.bean.MeetingNewRoomStateBean;
import com.yuexun.dhdoctor.module.meetingNew.bean.MeetingNewRoomStateOneBean;
import com.yuexun.dhdoctor.widget.ToastDialog;

import org.kymjs.kjframe.widget.AdapterHolder;
import org.kymjs.kjframe.widget.KJAdapter;

import java.util.Collection;

/**
 * Created by wangt on 2017/12/28.
 */

public class MeetingNewRoomStateAdapter extends KJAdapter<MeetingNewRoomStateBean> {

    //会议室状态 0：全部   1：空闲   2：占用  3：锁定
    private int userFlag = 0;

    //0：单选  2：双选
    private int type = 0;

    public void setType(int aDo) {
        type = aDo;
        notifyDataSetChanged();
    }

    public void setUserFlag(int userFlag) {
        this.userFlag = userFlag;
        notifyDataSetChanged();
    }

    public MeetingNewRoomStateAdapter(AbsListView view, Collection<MeetingNewRoomStateBean> mDatas, int itemLayoutId) {
        super(view, mDatas, itemLayoutId);
    }

    @Override
    public void convert(final AdapterHolder helper, final MeetingNewRoomStateBean item, boolean isScrolling, final int position) {
        super.convert(helper, item, isScrolling, position);
        TextView tvRoom = helper.getView(R.id.tv_room_name);
        CheckBox checkRoom = helper.getView(R.id.checkbox_room);
        TextView tv_1 = helper.getView(R.id.tv_1);
        TextView tv_2 = helper.getView(R.id.tv_2);
        TextView tv_3 = helper.getView(R.id.tv_3);
        TextView tv_4 = helper.getView(R.id.tv_4);
        TextView tv_5 = helper.getView(R.id.tv_5);
        TextView tv_6 = helper.getView(R.id.tv_6);
        TextView tv_7 = helper.getView(R.id.tv_7);
        TextView tv_8 = helper.getView(R.id.tv_8);
        TextView tv_9 = helper.getView(R.id.tv_9);
        TextView tv_10 = helper.getView(R.id.tv_10);
        TextView tv_11 = helper.getView(R.id.tv_11);
        TextView tv_12 = helper.getView(R.id.tv_12);
        TextView tv_13 = helper.getView(R.id.tv_13);
        TextView tv_14 = helper.getView(R.id.tv_14);
        TextView tv_15 = helper.getView(R.id.tv_15);
        TextView tv_16 = helper.getView(R.id.tv_16);
        TextView tv_17 = helper.getView(R.id.tv_17);
        TextView tv_18 = helper.getView(R.id.tv_18);
        TextView tv_19 = helper.getView(R.id.tv_19);
        TextView tv_20 = helper.getView(R.id.tv_20);

        LinearLayout ll_1 = helper.getView(R.id.ll_1);
        LinearLayout ll_2 = helper.getView(R.id.ll_2);
        LinearLayout ll_3 = helper.getView(R.id.ll_3);
        LinearLayout ll_4 = helper.getView(R.id.ll_4);
        LinearLayout ll_5 = helper.getView(R.id.ll_5);
        LinearLayout ll_6 = helper.getView(R.id.ll_6);
        LinearLayout ll_7 = helper.getView(R.id.ll_7);
        LinearLayout ll_8 = helper.getView(R.id.ll_8);
        LinearLayout ll_9 = helper.getView(R.id.ll_9);
        LinearLayout ll_10 = helper.getView(R.id.ll_10);
        LinearLayout ll_11 = helper.getView(R.id.ll_11);
        LinearLayout ll_12 = helper.getView(R.id.ll_12);
        LinearLayout ll_13 = helper.getView(R.id.ll_13);
        LinearLayout ll_14 = helper.getView(R.id.ll_14);
        LinearLayout ll_15 = helper.getView(R.id.ll_15);
        LinearLayout ll_16 = helper.getView(R.id.ll_16);
        LinearLayout ll_17 = helper.getView(R.id.ll_17);
        LinearLayout ll_18 = helper.getView(R.id.ll_18);
        LinearLayout ll_19 = helper.getView(R.id.ll_19);
        LinearLayout ll_20 = helper.getView(R.id.ll_20);

        final CheckBox checkBox_1 = helper.getView(R.id.checkbox_1);
        final CheckBox checkBox_2 = helper.getView(R.id.checkbox_2);
        final CheckBox checkBox_3 = helper.getView(R.id.checkbox_3);
        final CheckBox checkBox_4 = helper.getView(R.id.checkbox_4);
        final CheckBox checkBox_5 = helper.getView(R.id.checkbox_5);
        final CheckBox checkBox_6 = helper.getView(R.id.checkbox_6);
        final CheckBox checkBox_7 = helper.getView(R.id.checkbox_7);
        final CheckBox checkBox_8 = helper.getView(R.id.checkbox_8);
        final CheckBox checkBox_9 = helper.getView(R.id.checkbox_9);
        final CheckBox checkBox_10 = helper.getView(R.id.checkbox_10);
        final CheckBox checkBox_11 = helper.getView(R.id.checkbox_11);
        final CheckBox checkBox_12 = helper.getView(R.id.checkbox_12);
        final CheckBox checkBox_13 = helper.getView(R.id.checkbox_13);
        final CheckBox checkBox_14 = helper.getView(R.id.checkbox_14);
        final CheckBox checkBox_15 = helper.getView(R.id.checkbox_15);
        final CheckBox checkBox_16 = helper.getView(R.id.checkbox_16);
        final CheckBox checkBox_17 = helper.getView(R.id.checkbox_17);
        final CheckBox checkBox_18 = helper.getView(R.id.checkbox_18);
        final CheckBox checkBox_19 = helper.getView(R.id.checkbox_19);
        final CheckBox checkBox_20 = helper.getView(R.id.checkbox_20);

        tvRoom.setText(item.getRoomName());

        //设置选中数据   未选中数据
        if (item.isSelect()) {
            checkRoom.setChecked(true);
        } else {
            checkRoom.setChecked(false);
        }
        for (MeetingNewRoomStateOneBean oneTimeState : item.getOneTimeState()) {
            switch (oneTimeState.getTimeName()) {
                case "1":
                    setCheck(checkBox_1, oneTimeState);
                    break;
                case "2":
                    setCheck(checkBox_2, oneTimeState);
                    break;
                case "3":
                    setCheck(checkBox_3, oneTimeState);
                    break;
                case "4":
                    setCheck(checkBox_4, oneTimeState);
                    break;
                case "5":
                    setCheck(checkBox_5, oneTimeState);
                    break;
                case "6":
                    setCheck(checkBox_6, oneTimeState);
                    break;
                case "7":
                    setCheck(checkBox_7, oneTimeState);
                    break;
                case "8":
                    setCheck(checkBox_8, oneTimeState);
                    break;
                case "9":
                    setCheck(checkBox_9, oneTimeState);
                    break;
                case "10":
                    setCheck(checkBox_10, oneTimeState);
                    break;
                case "11":
                    setCheck(checkBox_11, oneTimeState);
                    break;
                case "12":
                    setCheck(checkBox_12, oneTimeState);
                    break;
                case "13":
                    setCheck(checkBox_13, oneTimeState);
                    break;
                case "14":
                    setCheck(checkBox_14, oneTimeState);
                    break;
                case "15":
                    setCheck(checkBox_15, oneTimeState);
                    break;
                case "16":
                    setCheck(checkBox_16, oneTimeState);
                    break;
                case "17":
                    setCheck(checkBox_17, oneTimeState);
                    break;
                case "18":
                    setCheck(checkBox_18, oneTimeState);
                    break;
                case "19":
                    setCheck(checkBox_19, oneTimeState);
                    break;
                case "20":
                    setCheck(checkBox_20, oneTimeState);
                    break;
            }
        }

        if (type == 0) {
            checkRoom.setVisibility(View.GONE);
            checkBox_1.setVisibility(View.GONE);
            checkBox_2.setVisibility(View.GONE);
            checkBox_3.setVisibility(View.GONE);
            checkBox_4.setVisibility(View.GONE);
            checkBox_5.setVisibility(View.GONE);
            checkBox_6.setVisibility(View.GONE);
            checkBox_7.setVisibility(View.GONE);
            checkBox_8.setVisibility(View.GONE);
            checkBox_9.setVisibility(View.GONE);
            checkBox_10.setVisibility(View.GONE);
            checkBox_11.setVisibility(View.GONE);
            checkBox_12.setVisibility(View.GONE);
            checkBox_13.setVisibility(View.GONE);
            checkBox_14.setVisibility(View.GONE);
            checkBox_15.setVisibility(View.GONE);
            checkBox_16.setVisibility(View.GONE);
            checkBox_17.setVisibility(View.GONE);
            checkBox_18.setVisibility(View.GONE);
            checkBox_19.setVisibility(View.GONE);
            checkBox_20.setVisibility(View.GONE);
        } else {
            checkRoom.setVisibility(View.VISIBLE);
            for (MeetingNewRoomStateOneBean data : item.getOneTimeState()) {
                switch (data.getTimeName()) {
                    case "1":
                        if (data.getTimestate() == 1) {
                            checkBox_1.setVisibility(View.VISIBLE);
                        } else {
                            checkBox_1.setVisibility(View.GONE);
                        }
                        break;
                    case "2":
                        if (data.getTimestate() == 1) {
                            checkBox_2.setVisibility(View.VISIBLE);
                        } else {
                            checkBox_2.setVisibility(View.GONE);
                        }
                        break;
                    case "3":
                        if (data.getTimestate() == 1) {
                            checkBox_3.setVisibility(View.VISIBLE);
                        } else {
                            checkBox_3.setVisibility(View.GONE);
                        }
                        break;
                    case "4":
                        if (data.getTimestate() == 1) {
                            checkBox_4.setVisibility(View.VISIBLE);
                        } else {
                            checkBox_4.setVisibility(View.GONE);
                        }
                        break;
                    case "5":
                        if (data.getTimestate() == 1) {
                            checkBox_5.setVisibility(View.VISIBLE);
                        } else {
                            checkBox_5.setVisibility(View.GONE);
                        }
                        break;
                    case "6":
                        if (data.getTimestate() == 1) {
                            checkBox_6.setVisibility(View.VISIBLE);
                        } else {
                            checkBox_6.setVisibility(View.GONE);
                        }
                        break;
                    case "7":
                        if (data.getTimestate() == 1) {
                            checkBox_7.setVisibility(View.VISIBLE);
                        } else {
                            checkBox_7.setVisibility(View.GONE);
                        }
                        break;
                    case "8":
                        if (data.getTimestate() == 1) {
                            checkBox_8.setVisibility(View.VISIBLE);
                        } else {
                            checkBox_8.setVisibility(View.GONE);
                        }
                        break;
                    case "9":
                        if (data.getTimestate() == 1) {
                            checkBox_9.setVisibility(View.VISIBLE);
                        } else {
                            checkBox_9.setVisibility(View.GONE);
                        }
                        break;
                    case "10":
                        if (data.getTimestate() == 1) {
                            checkBox_10.setVisibility(View.VISIBLE);
                        } else {
                            checkBox_10.setVisibility(View.GONE);
                        }
                        break;
                    case "11":
                        if (data.getTimestate() == 1) {
                            checkBox_11.setVisibility(View.VISIBLE);
                        } else {
                            checkBox_11.setVisibility(View.GONE);
                        }
                        break;
                    case "12":
                        if (data.getTimestate() == 1) {
                            checkBox_12.setVisibility(View.VISIBLE);
                        } else {
                            checkBox_12.setVisibility(View.GONE);
                        }
                        break;
                    case "13":
                        if (data.getTimestate() == 1) {
                            checkBox_13.setVisibility(View.VISIBLE);
                        } else {
                            checkBox_13.setVisibility(View.GONE);
                        }
                        break;
                    case "14":
                        if (data.getTimestate() == 1) {
                            checkBox_14.setVisibility(View.VISIBLE);
                        } else {
                            checkBox_14.setVisibility(View.GONE);
                        }
                        break;
                    case "15":
                        if (data.getTimestate() == 1) {
                            checkBox_15.setVisibility(View.VISIBLE);
                        } else {
                            checkBox_15.setVisibility(View.GONE);
                        }
                        break;
                    case "16":
                        if (data.getTimestate() == 1) {
                            checkBox_16.setVisibility(View.VISIBLE);
                        } else {
                            checkBox_16.setVisibility(View.GONE);
                        }
                        break;
                    case "17":
                        if (data.getTimestate() == 1) {
                            checkBox_17.setVisibility(View.VISIBLE);
                        } else {
                            checkBox_17.setVisibility(View.GONE);
                        }
                        break;
                    case "18":
                        if (data.getTimestate() == 1) {
                            checkBox_18.setVisibility(View.VISIBLE);
                        } else {
                            checkBox_18.setVisibility(View.GONE);
                        }
                        break;
                    case "19":
                        if (data.getTimestate() == 1) {
                            checkBox_19.setVisibility(View.VISIBLE);
                        } else {
                            checkBox_19.setVisibility(View.GONE);
                        }
                        break;
                    case "20":
                        if (data.getTimestate() == 1) {
                            checkBox_20.setVisibility(View.VISIBLE);
                        } else {
                            checkBox_20.setVisibility(View.GONE);
                        }
                        break;

                }
            }

            //选择选中会议室
            checkRoom.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (!item.isSelect()) {
                        selectRoom(item);
                        notifyDataSetChanged();
                    } else {
                        if (item.isSelect()) {
                            item.setSelect(false);
                        } else {
                            for (MeetingNewRoomStateBean data : mDatas) {
                                data.setSelect(false);
                            }
                            item.setSelect(true);
                        }
                        notifyDataSetChanged();
                    }
                    /*if (!item.isSelect()) {
                        selectRoom(item);
                        notifyDataSetChanged();
                    } else {
                        for (MeetingNewRoomStateBean data : mDatas) {
                            data.setSelect(false);
                        }
                        item.setSelect(true);
                        notifyDataSetChanged();
                    }*/
                }
            });

            //时间点checkbox点击事件
            setOnClick(checkBox_1, 1, item);
            setOnClick(checkBox_2, 2, item);
            setOnClick(checkBox_3, 3, item);
            setOnClick(checkBox_4, 4, item);
            setOnClick(checkBox_5, 5, item);
            setOnClick(checkBox_6, 6, item);
            setOnClick(checkBox_7, 7, item);
            setOnClick(checkBox_8, 8, item);
            setOnClick(checkBox_9, 9, item);
            setOnClick(checkBox_10, 10, item);
            setOnClick(checkBox_11, 11, item);
            setOnClick(checkBox_12, 12, item);
            setOnClick(checkBox_13, 13, item);
            setOnClick(checkBox_14, 14, item);
            setOnClick(checkBox_15, 15, item);
            setOnClick(checkBox_16, 16, item);
            setOnClick(checkBox_17, 17, item);
            setOnClick(checkBox_18, 18, item);
            setOnClick(checkBox_19, 19, item);
            setOnClick(checkBox_20, 20, item);

        }

        //显示状态名称
        for (MeetingNewRoomStateOneBean oneTimestate : item.getOneTimeState()) {
            switch (oneTimestate.getTimeName()) {
                case "1":
                    setShowText(tv_1, oneTimestate);
                    break;
                case "2":
                    setShowText(tv_2, oneTimestate);
                    break;
                case "3":
                    setShowText(tv_3, oneTimestate);
                    break;
                case "4":
                    setShowText(tv_4, oneTimestate);
                    break;
                case "5":
                    setShowText(tv_5, oneTimestate);
                    break;
                case "6":
                    setShowText(tv_6, oneTimestate);
                    break;
                case "7":
                    setShowText(tv_7, oneTimestate);
                    break;
                case "8":
                    setShowText(tv_8, oneTimestate);
                    break;
                case "9":
                    setShowText(tv_9, oneTimestate);
                    break;
                case "10":
                    setShowText(tv_10, oneTimestate);
                    break;
                case "11":
                    setShowText(tv_11, oneTimestate);
                    break;
                case "12":
                    setShowText(tv_12, oneTimestate);
                    break;
                case "13":
                    setShowText(tv_13, oneTimestate);
                    break;
                case "14":
                    setShowText(tv_14, oneTimestate);
                    break;
                case "15":
                    setShowText(tv_15, oneTimestate);
                    break;
                case "16":
                    setShowText(tv_16, oneTimestate);
                    break;
                case "17":
                    setShowText(tv_17, oneTimestate);
                    break;
                case "18":
                    setShowText(tv_18, oneTimestate);
                    break;
                case "19":
                    setShowText(tv_19, oneTimestate);
                    break;
                case "20":
                    setShowText(tv_20, oneTimestate);
                    break;
            }
        }

            //会议室详情查看
            setItem(tv_1,ll_1, 1, item);
            setItem(tv_2,ll_2, 2, item);
            setItem(tv_3,ll_3, 3, item);
            setItem(tv_4,ll_4, 4, item);
            setItem(tv_5,ll_5, 5, item);
            setItem(tv_6,ll_6, 6, item);
            setItem(tv_7,ll_7, 7, item);
            setItem(tv_8,ll_8, 8, item);
            setItem(tv_9,ll_9, 9, item);
            setItem(tv_10,ll_10, 10, item);
            setItem(tv_11,ll_11, 11, item);
            setItem(tv_12,ll_12, 12, item);
            setItem(tv_13,ll_13, 13, item);
            setItem(tv_14,ll_14, 14, item);
            setItem(tv_15,ll_15, 15, item);
            setItem(tv_16,ll_16, 16, item);
            setItem(tv_17,ll_17, 17, item);
            setItem(tv_18,ll_18, 18, item);
            setItem(tv_19,ll_19, 19, item);
            setItem(tv_20,ll_20, 20, item);

    }

    //设置选中
    private void setCheck(CheckBox checkbox, MeetingNewRoomStateOneBean oneTimeState) {
        if (oneTimeState.getTimestate() == 1 && oneTimeState.isSelect()) {
            checkbox.setChecked(true);
        } else {
            checkbox.setChecked(false);
        }
    }

    //显示状态文字
    private void setShowText(TextView tv, MeetingNewRoomStateOneBean oneTimeState) {
        if (userFlag == 0) {              //显示全部
            if (oneTimeState.getTimestate() == 1) {
                tv.setText("(空闲)");
                tv.setTextColor(mCxt.getResources().getColor(R.color.main_text_01));
            } else if (oneTimeState.getTimestate() == 2) {
                tv.setText("(占用)");
                tv.setTextColor(mCxt.getResources().getColor(R.color.red));
            } else if (oneTimeState.getTimestate() == 3) {
                tv.setText("(锁定)");
                tv.setTextColor(mCxt.getResources().getColor(R.color.yellow));
            } else {
                tv.setText("");
            }
        } else if (userFlag == 1) {       //显示空闲
            if (oneTimeState.getTimestate() == 1) {
                tv.setText("(空闲)");
                tv.setTextColor(mCxt.getResources().getColor(R.color.main_text_01));
            } else {
                tv.setText("");
            }
        } else if (userFlag == 2) {        //显示占用
            if (oneTimeState.getTimestate() == 2) {
                tv.setText("(占用)");
                tv.setTextColor(mCxt.getResources().getColor(R.color.red));
            } else {
                tv.setText("");
            }
        } else if (userFlag == 3) {        //显示锁定
            if (oneTimeState.getTimestate() == 3) {
                tv.setText("(锁定)");
                tv.setTextColor(mCxt.getResources().getColor(R.color.yellow));
            } else {
                tv.setText("");
            }
        }
    }

    //设置单个会议室选中
    private void selectRoom(MeetingNewRoomStateBean item) {
        for (MeetingNewRoomStateBean data : mDatas) {
            data.setSelect(false);
            for (MeetingNewRoomStateOneBean data_2 : data.getOneTimeState()) {
                data_2.setSelect(false);
            }
        }
        item.setSelect(true);
    }

    //设置点击事件
    private void setOnClick(CheckBox checkBox, final int tv_num, final MeetingNewRoomStateBean item) {

        checkBox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (type == 1) {     //单选
//                    for (MeetingNewRoomStateOneBean data : item.getOneTimeState()) {
//                        data.setSelect(false);
//                        if (data.getTimeName().equals(tv_num + "")) {
//                            data.setSelect(true);
//                        }
//                    }
                    boolean isSelect = false;
                    for (MeetingNewRoomStateOneBean data : item.getOneTimeState()) {
                        if (data.getTimeName().equals(tv_num + "")) {
                            isSelect = data.isSelect();
                            if (data.isSelect()) {
                                data.setSelect(false);
                                break;
                            }
                        }
                    }
                    if (!isSelect) {
                        if (!item.isSelect()) {
                            selectRoom(item);
                        }

                        for (MeetingNewRoomStateOneBean data : item.getOneTimeState()) {
                            data.setSelect(false);
                            if (data.getTimeName().equals(tv_num + "")) {
                                data.setSelect(true);
                            }
                        }
                    }
                } else {             //双选
                    if (!item.isSelect()) {
                        selectRoom(item);
                    }
                    //选中个数
                    int select = 0;
                    boolean isSelect = false;
                    for (MeetingNewRoomStateOneBean data : item.getOneTimeState()) {
                        if (data.getTimeName().equals(tv_num + "")) {
                            isSelect = data.isSelect();
                            if (data.isSelect()) {
                                data.setSelect(false);
                                break;
                            }
                        }
                    }
                    if (!isSelect) {
                        for (MeetingNewRoomStateOneBean data : item.getOneTimeState()) {
                            if (data.isSelect()) {
                                select = select + 1;
                            }
                        }
                        if (select < 2) {
                            for (MeetingNewRoomStateOneBean data : item.getOneTimeState()) {
                                if (data.getTimeName().equals(tv_num + "")) {
                                    data.setSelect(true);
                                }
                            }
                        } else {
                            new ToastDialog(mCxt, "已勾选开始与结束时间！").show();
                        }
                    }
                }
                notifyDataSetChanged();
            }
        });
    }
    private void setItem(final TextView textView, LinearLayout linearLayout, final int tv_num, final MeetingNewRoomStateBean item) {
        linearLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                switch (tv_num){
                    case 1:
                        if(textView.getText().toString().equals("(占用)"))
                            onItemAddClick.onItemClick(item.getRoomName(), "08:00:00", "08:30:00");
                        break;
                    case 2:
                        if(textView.getText().toString().equals("(占用)"))
                            onItemAddClick.onItemClick(item.getRoomName(), "08:30:00", "09:00:00");
                        break;
                    case 3:
                        if(textView.getText().toString().equals("(占用)"))
                            onItemAddClick.onItemClick(item.getRoomName(), "09:00:00", "09:30:00");
                        break;
                    case 4:
                        if(textView.getText().toString().equals("(占用)"))
                            onItemAddClick.onItemClick(item.getRoomName(),"09:30:00","10:00:00");
                        break;
                    case 5:
                        if(textView.getText().toString().equals("(占用)"))
                            onItemAddClick.onItemClick(item.getRoomName(),"10:00:00","10:30:00");
                        break;
                    case 6:
                        if(textView.getText().toString().equals("(占用)"))
                            onItemAddClick.onItemClick(item.getRoomName(),"10:30:00","11:00:00");
                        break;
                    case 7:
                        if(textView.getText().toString().equals("(占用)"))
                            onItemAddClick.onItemClick(item.getRoomName(),"11:00:00","11:30:00");
                        break;
                    case 8:
                        if(textView.getText().toString().equals("(占用)"))
                            onItemAddClick.onItemClick(item.getRoomName(),"11:30:00","12:00:00");
                        break;
                    case 9:
                        if(textView.getText().toString().equals("(占用)"))
                            onItemAddClick.onItemClick(item.getRoomName(),"12:00:00","12:30:00");
                        break;
                    case 10:
                        if(textView.getText().toString().equals("(占用)"))
                            onItemAddClick.onItemClick(item.getRoomName(),"12:30:00","13:00:00");
                        break;
                    case 11:
                        if(textView.getText().toString().equals("(占用)"))
                            onItemAddClick.onItemClick(item.getRoomName(),"13:00:00","13:30:00");
                        break;
                    case 12:
                        if(textView.getText().toString().equals("(占用)"))
                            onItemAddClick.onItemClick(item.getRoomName(),"13:30:00","14:00:00");
                        break;
                    case 13:
                        if(textView.getText().toString().equals("(占用)"))
                            onItemAddClick.onItemClick(item.getRoomName(),"14:00:00","14:30:00");
                        break;
                    case 14:
                        if(textView.getText().toString().equals("(占用)"))
                            onItemAddClick.onItemClick(item.getRoomName(),"14:30:00","15:00:00");
                        break;
                    case 15:
                        if(textView.getText().toString().equals("(占用)"))
                            onItemAddClick.onItemClick(item.getRoomName(),"15:00:00","15:30:00");
                        break;
                    case 16:
                        if(textView.getText().toString().equals("(占用)"))
                            onItemAddClick.onItemClick(item.getRoomName(),"15:30:00","16:00:00");
                        break;
                    case 17:
                        if(textView.getText().toString().equals("(占用)"))
                            onItemAddClick.onItemClick(item.getRoomName(),"16:00:00","16:30:00");
                        break;
                    case 18:
                        onItemAddClick.onItemClick(item.getRoomName(),"16:30:00","17:00:00");
                        break;
                    case 19:
                        if(textView.getText().toString().equals("(占用)"))
                            onItemAddClick.onItemClick(item.getRoomName(),"17:00:00","17:30:00");
                        break;
                    case 20:
                        if(textView.getText().toString().equals("(占用)"))
                            onItemAddClick.onItemClick(item.getRoomName(),"17:30:00","18:00:00");
                        break;
                }
            }
        });
    }


    public static interface OnAddClickListener {
        public void onItemClick(String roomName, String startDate, String endDate); //传递boolean类型数据给activity
    }

    OnAddClickListener onItemAddClick;
    public void setOnAddClickListener(OnAddClickListener onItemAddClick) {
        this.onItemAddClick = onItemAddClick;
    }
}
